package io.gitee.chearnee.fw.common.utils;

import lombok.experimental.UtilityClass;

import java.math.BigDecimal;

/**
 * @author cn
 * @version 1.0
 * @description
 * @date 2023/7/19 13:55
 */
@UtilityClass
public class NumberUtil {

    /**
     * 判断两个数是否值相等
     *
     * @param a
     * @param b
     * @return
     */
    public static boolean valueEquals(Number a, Number b) {
        if (a == null && b == null) {
            return true;
        }
        if (a == null || b == null) {
            return false;
        }

        return a.byteValue() == b.byteValue();
    }

    public static void main(String[] args) {
        double a = 127;
        double b = -128;
        System.out.println(valueEquals(a, b));
    }

    /**
     * 判断是一个数是否是正数
     *
     * @param number
     * @return
     */
    public static boolean isPositiveNumber(Number number) {
        return number != null && new BigDecimal(number.toString()).compareTo(BigDecimal.ZERO) > 0;
    }
}
